package model

import "gorm.io/gorm"

/**
 * 库存信息
 */
type Inventory struct {
	gorm.Model
	//基本信息
	UserId            int    `gorm:"column:user_id" form:"userId" json:"userId"`
	PurchaseProductId int    `gorm:"column:purchase_product_id" form:"purchaseProductId" json:"purchaseProductId"`
	ProductId         int    `gorm:"column:product_id" form:"productId" json:"productId"`
	Date              string `gorm:"column:date" form:"date" json:"date"`

	Supplier              string                  `gorm:"column:supplier" form:"supplier" json:"supplier"`                       //供货商
	Warehouse             string                  `gorm:"column:warehouse" form:"warehouse" json:"warehouse"`                    //冷库
	PurchasePrice         float64                 `gorm:"column:purchase_price" form:"purchasePrice" json:"purchasePrice"`       //采购单价
	PurchaseNumber        int                     `gorm:"column:purchase_number" form:"purchaseNumber" json:"purchaseNumber"`    //采购件数
	PurchaseWeight        float64                 `gorm:"column:purchase_weight" form:"purchaseWeight" json:"purchaseWeight"`    //采购重量
	InventoryNumber       int                     `gorm:"column:inventory_number" form:"inventoryNumber" json:"inventoryNumber"` //库存件数
	InventoryWeight       float64                 `gorm:"column:inventory_weight" form:"inventoryWeight" json:"inventoryWeight"` //库存重量
	TotalAmount           float64                 `gorm:"column:total_amount" form:"totalAmount" json:"totalAmount"`             //货款总金额
	DiscountAmount        float64                 `gorm:"column:discount_amount" form:"discountAmount" json:"discountAmount"`    //优惠金额
	PaymentAmount         float64                 `gorm:"column:payment_amount" form:"paymentAmount" json:"paymentAmount"`       //付款金额
	InventorySalesProduct []InventorySalesProduct `gorm:"ForeignKey:InventoryId;AssociationForeignKey:Id" json:"salesList"`      //该商品的销售记录供货商

	FactoryNo     string `gorm:"column:factory_no;->" form:"factoryNo" json:"factoryNo"`            //工厂号
	ProductName   string `gorm:"column:product_name;->" form:"productName" json:"productName"`      //商品名称
	ContractNo    string `gorm:"column:contract_no;->" form:"contractNo" json:"contractNo"`         //合同编号
	ContainerNo   string `gorm:"column:container_no;->" form:"containerNo" json:"containerNo"`      //集装箱号
	Specification string `gorm:"column:specification;->" form:"specification" json:"specification"` //规格
}

type InventorySalesOrder struct {
	gorm.Model
	//基本信息
	UserId                int                     `gorm:"column:user_id" form:"userId" json:"userId"`
	CustomerId            int                     `gorm:"column:customer_id" form:"customerId" json:"customerId"`
	SellerId              int                     `gorm:"column:seller_id" form:"sellerId" json:"sellerId"`
	Date                  string                  `gorm:"column:date" form:"date" json:"date"`
	Type                  string                  `gorm:"column:type" form:"type" json:"type"`                                //销售、销售退货
	Car                   string                  `gorm:"column:car" form:"car" json:"car"`                                   //销售、销售退货
	Area                  string                  `gorm:"column:area" form:"area" json:"area"`                                //销售、销售退货
	TotalAmount           float64                 `gorm:"column:total_amount" form:"totalAmount" json:"totalAmount"`          //货款总金额
	ArrearsAmount         float64                 `gorm:"column:arrears_amount" form:"arrearsAmount" json:"arrearsAmount"`    //货款总金额
	DiscountAmount        float64                 `gorm:"column:discount_amount" form:"discountAmount" json:"discountAmount"` //优惠金额
	PaymentAmount         float64                 `gorm:"column:payment_amount" form:"paymentAmount" json:"paymentAmount"`    //付款金额
	Remark                string                  `gorm:"column:remark" form:"remark" json:"remark"`                          //付款金额
	CustomerName          string                  `gorm:"column:name;->" form:"customerName" json:"customerName"`
	SellerName            string                  `gorm:"column:seller_name;->" form:"sellerName" json:"sellerName"` //客户名称
	InventorySalesProduct []InventorySalesProduct `gorm:"ForeignKey:OrderId;AssociationForeignKey:Id" format:"salesProductList" json:"salesProductList"`
	BankStatement         []BankStatement         `gorm:"ForeignKey:FunctionId;AssociationForeignKey:Id" format:"statementList" json:"statementList"` //结算单列表
}

type InventorySalesProduct struct {
	gorm.Model
	UserId            int     `gorm:"column:user_id" form:"userId" json:"userId"`
	ProductId         int     `gorm:"column:product_id" form:"productId" json:"productId"`
	InventoryId       int     `gorm:"column:inventory_id" form:"inventoryId" json:"inventoryId"`
	PurchaseProductId int     `gorm:"column:purchase_product_id" form:"purchaseProductId" json:"purchaseProductId"`
	CustomerId        int     `gorm:"column:customer_id" form:"customerId" json:"customerId"`
	SellerId          int     `gorm:"column:seller_id" form:"sellerId" json:"sellerId"`
	OrderId           int     `gorm:"column:order_id" form:"orderId" json:"orderId"`
	Date              string  `gorm:"column:date" form:"date" json:"date"`
	Type              string  `gorm:"column:type" form:"type" json:"type"`                       //销售、销售退货
	SalesPrice        float64 `gorm:"column:sales_price" form:"salesPrice" json:"salesPrice"`    //采购单价
	SalesNumber       int     `gorm:"column:sales_number" form:"salesNumber" json:"salesNumber"` //采购件数
	SalesWeight       float64 `gorm:"column:sales_weight" form:"salesWeight" json:"salesWeight"` //采购重量
	TotalAmount       float64 `gorm:"column:total_amount" form:"totalAmount" json:"totalAmount"` //货款总金额
	Remark            string

	//只返回，不新增
	Warehouse     string `gorm:"column:warehouse;->" form:"warehouse" json:"warehouse"`     //所在冷库
	Supplier      string `gorm:"column:supplier;->" form:"supplier" json:"supplier"`        //供货商
	CustomerName  string `gorm:"column:name;->" form:"customerName" json:"customerName"`    //客户名称
	SellerName    string `gorm:"column:seller_name;->" form:"sellerName" json:"sellerName"` //客户名称
	FactoryNo     string `gorm:"->" form:"factoryNo" json:"factoryNo"`                      //工厂号
	ProductName   string `gorm:"->" form:"productName" json:"productName"`                  //商品名称
	Specification string `gorm:"->" form:"specification" json:"specification"`              //规格
	ContractNo    string `gorm:"->" form:"contractNo" json:"contractNo"`                    //合同编号
	ContainerNo   string `gorm:"->" form:"containerNo" json:"containerNo"`                  //集装箱号
}
